<template>
  <div class="card-widget card-categories">
    <div class="item-headline">
      <i class="haofont hao-icon-folder-open"></i>
      <span>分类</span>
    </div>
    <div class="aside-list">
      <ul class="card-category-list">
        <li class="card-category-list-item" v-for="(category , index) in categoryList" :key="index">
          <a class="card-category-list-link" href="javascript:void(0);" @click="toPath('categories?id=' + category.id)">
            <span class="card-category-list-name" :title="category.name">{{ category.name }}</span>
            <span class="card-category-list-count">{{ category.count }}</span>
          </a>
        </li>
      </ul>
    </div>
  </div>
</template>

<script setup>
import {computed} from "vue";
import {useRouter} from 'vue-router';
import store from "../../store/index.js";

const router = useRouter();
const categoryList = computed(() => store.state.data.asideCategoryList);

const toPath = (path) => {
  router.push(path)
}
</script>

<style scoped>
</style>
